package JiHeDemo.mygenneric;

import JiHeDemo.Student;

import java.util.Iterator;
import java.util.TreeSet;

public class Set2 {
	public static void main(String[] args) {
		TreeSet<Student> set = new TreeSet();
		Student s1 = new Student("a", 10);
		Student s2 = new Student("d", 12);
		Student s3 = new Student("c", 13);
		Student s4 = new Student("b", 16);
		Student s5 = new Student("b", 14);
		set.add(s4);
		set.add(s3);
		set.add(s2);
		set.add(s1);
		set.add(s5);
		System.out.println("元素个数:" + set.size());
		System.out.println(set);
		set.remove(s5);
		System.out.println(set.size());
		for (Student s : set) {
			System.out.println(s);
		}
		System.out.println("=======");
		Iterator it = set.iterator();
		while (it.hasNext()) {
			System.out.println(it.next());
		}
	}
}
